package per.ace.annotation.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import per.ace.annotation.util.BeanUtil;

import java.util.Collection;

/**
 * 切面方法
 */
@Component
@Aspect
public class SetFieldValueAspect {
    @Autowired
    BeanUtil beanUtil;
    @Around("@annotation(per.ace.annotation.annotation.NeedSetValueField)")
    public Object doSetFieldValue(ProceedingJoinPoint point) throws Throwable {
        Object obj = point.proceed(); //执行原方法 获取结果集
        //List == [{id:1,consumerId:1,customerName:xxx @NeedSetValue()}]
        //操作结果集，将值设置进结果中
        beanUtil.setFieldValueForCol((Collection) obj);
        return obj;
    }
}
